package net.maxwoods.listener;

import net.maxwoods.config.RootConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.annotation.WebListener;

@WebListener
public class SpringListener extends ContextLoaderListener {

    private static Logger logger=LoggerFactory.getLogger(SpringListener.class);

    @Override
    public void contextInitialized(ServletContextEvent event) {
        ServletContext sc=event.getServletContext();
        sc.setInitParameter("contextClass",AnnotationConfigWebApplicationContext.class.getName());
        sc.setInitParameter("contextConfigLocation", RootConfig.class.getName());
        super.contextInitialized(event);
        logger.info("spring 初始化:{}",getClass().getName());
    }
}
